import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;

/**
 * 推荐方法Files.lines
 */
public class FilesLinesTest {
    public static void main(String[] args) {
        String fileName = "src/main/resources/static/TestReaderFile.txt";
        // 读取文件内容到Stream流中，按行读取
        try {
            Stream<String> lines = Files.lines(Paths.get(fileName));
            //Lambda表达式
            lines.forEach(s -> System.out.println(s));
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
